package com.example.administrator.pomelostreet;

import android.os.Build;
import android.os.Bundle;
import android.support.annotation.RequiresApi;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.support.v7.app.AppCompatActivity;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import com.example.administrator.pomelostreet.fragment.Mine_Fragment;

import com.example.administrator.pomelostreet.pinpai.fragment.PinPai_Fragment;
import com.example.administrator.pomelostreet.fragment.ShangXin_Fragment;
import com.example.administrator.pomelostreet.fragment.TaTa_Fragment;

import static android.icu.lang.UCharacter.GraphemeClusterBreak.T;

public class MainActivity extends AppCompatActivity {

    @RequiresApi(api = Build.VERSION_CODES.GINGERBREAD)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(getWindow().FEATURE_NO_TITLE);
        setContentView(R.layout.activity_main);
        final FragmentManager manager = getSupportFragmentManager();

        RadioGroup rg= (RadioGroup) findViewById(R.id.rg);
        RadioButton shangxin= (RadioButton) findViewById(R.id.shangxin);
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, int checkedId) {
                FragmentTransaction transaction = manager.beginTransaction();
                switch (checkedId){
                    case R.id.shangxin:
                        transaction.replace(R.id.ll,new ShangXin_Fragment());
                        transaction.commit();
                        break;
                    case R.id.pinpai:
                       transaction.replace(R.id.ll,new PinPai_Fragment(MainActivity.this));
                        transaction.commit();
                        break;
                    case R.id.tata:
                       transaction.replace(R.id.ll,new TaTa_Fragment(MainActivity.this));
                        transaction.commit();
                        break;
                    case R.id.gouwu:
                        break;
                    case R.id.me:
                       transaction.replace(R.id.ll,new Mine_Fragment());
                        transaction.commit();
                        break;

                }
            }
        });
        shangxin.setChecked(true);
    }
}
